import { HiMenu } from "../components/HiMenu";
import { createUUID } from "../utils";

export default class BaseNode {
  private _key = createUUID();
  get key() {
    return this._key;
  }
  element?: HTMLElement;
  protected _nodeType: VoucherNodeType = "voucher";
  get nodeType() {
    return this._nodeType;
  }

  protected _options: { name: string;[key: string]: any } = { name: "" };
  protected get options() {
    return { ...this._options };
  }

  protected isRootNode = true

  protected _changes: ((options: { [key: string]: any }) => void)[] = []

  protected menuView?: HiMenu

  constructor(isRootNode = true) {
    this.isRootNode = isRootNode;
  }

  setOptions(options: { [key: string]: any }) { };
  getOptions(): { [key: string]: any } { return this.options };
  setMenuView(menuView: HiMenu) { this.menuView = menuView };
  onChange(fn: (options: { [key: string]: any }) => void) { this._changes.push(fn) };
}